<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\jui\DatePicker;
use kartik\datetime\DateTimePicker;
use mdm\admin\components\Helper;
use backend\models\User;
/* @var $this yii\web\View */
/* @var $model backend\controllers\GoodsSearch */
/* @var $form yii\widgets\ActiveForm */

?>
<style>
   #searchForm .form-group{margin-right:10px;}
</style>

<div class="goods-search">

    <?php $form = ActiveForm::begin([
        'action' => ['index'],
        'method' => 'get',
        'options'=> ['class'=>'form-inline'],
        'id'=>'searchForm'
    ]); ?>


    <?= $form->field($model, 'goodsid')->textInput(['placeholder'=>'新蛋编码']); ?>
    <?= $form->field($model, 'goodsno')->textInput(); ?>
    <?php //echo  $form->field($model, 'goodsname')->textInput(); ?>

<?php if(User::getmyrole()!='供应商' ){ ?>
    <?php
    $model->gys=isset($goodssearch['gys'])?$goodssearch['gys']:'';
    echo  $form->field($model, 'gys')->dropDownList($allStatus) ?>
<?php } ?>


    <?php $inprice = Html::tag('label', "进货价", ['class' => 'control-label']);
    $inprice.=chr(10).chr(13);
     $inprice.= Html::dropDownList('GoodsSearch[upfee]',isset($goodssearch['upfee'])?$goodssearch['upfee']:0,[0=>'全部',1=>'上涨',2=>'下跌'],['class'=>'form-control']);
     $inprice .= Html::tag("div",'',['class'=>'help-block']);
    echo Html::tag('div', $inprice, ['class'=>'form-group field-goodssearch-inprice']);
     ?>


    <?php $checkstatus = Html::tag('label', "审核状态", ['class' => 'control-label']);
    $checkstatus.=chr(10).chr(13);
    $checkstatus.=  Html::dropDownList('GoodsSearch[check]',isset($goodssearch['check'])?$goodssearch['check']:5,[5=>'全部',0=>'待审核',1=>'一审通过',2=>'二审通过',3=>'审核通过',4=>'审核不通过'],['class'=>'form-control']);
    $checkstatus .= Html::tag("div",'',['class'=>'help-block']);
    ?>
    <?php echo Html::tag('div', $checkstatus, ['class'=>'form-group field-goodssearch-check']);?>
    <?php  echo $form->field($model, 'class')->dropDownList($classes) ?>

    <?php
        $uptime =  Html::tag('label', "更新时间", ['class' => 'control-label ']);
        $uptime .=chr(10).chr(13);
        $uptime .= DateTimePicker::widget([
                'name' => 'GoodsSearch[datefrom]',
                'options'=>[
                        'class'=>'form-control',
                        'autocomplete'=>'off'
                ],
                'pluginOptions'=>[
                        'format'=>'yyyy-mm-dd hh:ii:ss',

                ],
                'value'=>isset($goodssearch['datefrom'])?$goodssearch['datefrom']:'',
                'layout'=>'{input}{picker}'
        ]);
        $uptime .= Html::label('~');
        $uptime .= DateTimePicker::widget([
            'name' => 'GoodsSearch[dateto]',
            'options'=>[
                'class'=>'form-control',
                'autocomplete'=>'off'
            ],
            'pluginOptions'=>[
                'format'=>'yyyy-mm-dd hh:ii:ss',

            ],
            'value'=>isset($goodssearch['dateto'])?$goodssearch['dateto']:'',
            'layout'=>'{input}{picker}'
        ]);

        $uptime .= Html::tag("div",'',['class'=>'help-block']);
    ?>
    <?php echo Html::tag('div', $uptime, ['class'=>'form-group field-goodssearch-goodsno']);?>



    <?php  echo $form->field($model, 'export')->dropDownList([2=>'全部',1=>'已导出',0=>'未导出']) ?>

    <div class="form-group">
        <?= Html::submitButton('搜索', ['class' => 'btn btn-primary']) ?>
        <?= Html::Button('重置', ['class' => 'btn btn-default','onclick'=>'clearSearch()']) ?>
        <script>
            function clearSearch(){
                $('input').val('');
                $('select').val(0);
                $('select[name="GoodsSearch[check]"]').val(5);
                $('select[name="GoodsSearch[export]"]').val(2);
            }

        </script>
      <?php  if(Helper::checkRoute('export/out')) { ?>
        <?= Html::button('导出',['class' => 'btn btn-default','onclick'=>'$("#searchForm").attr("action","/export/out");$("#searchForm").submit();']) ?>
        <?php
      }?>
       <?= Html::tag("div",'',['class'=>'help-block']);?>
    </div>

    <?php ActiveForm::end(); ?>

</div>

